package com.situ.gym.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.situ.gym.pojo.UserComment;
import com.situ.gym.pojo.query.UserCommentQuery;
import com.situ.gym.service.IUserCommentService;
import com.situ.gym.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/comment")
public class UserCommentController {

    @Autowired
    private IUserCommentService commentService;

    @GetMapping("/list")
    public Result<IPage<UserComment>> list(UserCommentQuery query) {
        IPage<UserComment> page = commentService.list(query);
        return Result.ok(page);
    }

    @GetMapping("/selectAll")
    public Result<List<UserComment>> selectAll() {
        List<UserComment> list = commentService.list();
        return Result.ok(list);
    }

    @PostMapping("/add")
    public Result add(@RequestBody UserComment comment) {
        commentService.save(comment);
        return Result.ok("添加成功");
    }
}
